<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="UTF-8" />
	<title>创建新群</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-touch-fullscreen" content="yes">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<link rel="stylesheet" href="/qstatic/css/reset.css" />
	<link rel="stylesheet" href="/qstatic/css/animate.css" />
	<link rel="stylesheet" href="/qstatic/css/swiper-3.4.1.min.css" />
	<link rel="stylesheet" href="/qstatic/css/layout.css" />
	
	<script src="/qstatic/js/jquery-1.9.1.min.js"></script>
	<script src="/qstatic/js/zepto.min.js"></script>
	<script src="/qstatic/js/fontSize.js"></script>
	<script src="/qstatic/js/swiper-3.4.1.min.js"></script>
	<script src="/qstatic/js/wcPop/wcPop.js"></script>
			
			<script src="/qstatic/js/layui.js"></script>
	<link rel="stylesheet" href="/qstatic/js/css/layui.css" />
	
</head>
<body>
	
	<!-- <>微聊主容器 -->
	<div class="wechat__panel clearfix">
		<div class="wc__home-wrapper flexbox flex__direction-column">
			<!-- //顶部 -->
			<div class="wc__headerBar fixed">
				<div class="inner flexbox">
					<a class="back" href="javascript:;" onclick="history.back(-1);"></a>
					<h2 class="barTit flex1">创建新群</h2>
					<!--<a class="batBtn" href="javascript:;">保存</a>-->
				</div>
			</div>

			<!-- //个人信息页 -->
			<div class="wc__ucinfoPanel">
				<div class="wc__ucinfo-personal">
				<form action="/chat/addgroup" method="post" id="loginForm" autocomplete="on">
					<ul class="clearfix">
						<li>
							<!--<div class="item flexbox flex-alignc wc__material-cell">-->
							<!--	<label class="lbl flex1">群图标</label>-->
							<!--	<div id="shopimgdata">-->
							<!--	<img class="uimg" src="/qstatic/img/uimg/u__chat-img11.jpg" />-->
							<!--	<input type="hidden" name="grouptx" value ="/qstatic/img/uimg/u__chat-img11.jpg"/>-->
							<!--	</div>-->
							<!--	<input class="chooseImg" type="file" id="idzfilezt" accept="image/*" />-->
								
							<!--</div>-->
							<div class="item flexbox flex-alignc wc__material-cell">
								<label class="lbl flex1">群昵称</label>
								<input class="val" id="groupname" type="text" placeholder="吃喝玩乐群" />
							</div>
							<input type="hidden" name="userid" value =""/>
							<!--<div class="item flexbox flex-alignc wc__material-cell">
								<label class="lbl flex1">群号</label>
								<input class="val" name="" type="text" value="wQQ2018" />
							</div>-->
							<div class="item flexbox flex-alignc wc__material-cell">
								<textarea id="groupinfo" class="area flex1" placeholder="请输入群介绍"></textarea>
							</div>
							<div class="btns"><a style="margin: 5% 5% 10%;border-radius: 1.07rem;" class="wc__btn-primary btn__login" onclick="sumbit()">提交创建</a></div>
							
						</li>
					</ul>
					</form>
				</div>
			</div>

		</div>
	</div>


	<script type="text/javascript">
        function sumbit(){
            var groupname = $('#groupname').val();
            var groupinfo = $('#groupinfo').val();
            var regex = /^[^\s`~!@#$%^&*()\-+={}\[\]:;"'<>,.?\\/]+$/;
            if(!regex.test(groupname)) {
                layer.msg('输入内容包含特殊字符，请重新输入！');
                return false; // 阻止 prompt 关闭
            }
            $.post('/chat/addgroup', { // 替换 'your_endpoint_url' 为你的实际接口地址
                groupname: groupname,
                groupinfo: groupinfo
            }, function(response) {
                if(response.code == '1'){
                    layer.msg(response.msg);
                    setTimeout(function() {
                      window.location.href = "/chat/index";
                    }, 2000);
                }else{
                    layer.msg(response.msg);
                    
                }
            })
        }

		/** __公共函数 */
		$(function(){
			// ...
		});
		
		/** __自定函数 */
		$(function(){
			// ...
		});

		//头像上传
		function uploadPictx(formData) {
            var oReq = new XMLHttpRequest();
            oReq.open("POST", "/chat/grouptx?name=74&kf=14&zt=0", true);
            oReq.onload = function (oEvent) {
                if (oReq.status == 200) {
					//msgWrapper.innerHTML += oReq.response;
					//$('#msgWrapper').scrollTop( $('#msgWrapper')[0].scrollHeight );//滚动条至底部
					html=oReq.response;
					$('#shopimgdata').html(html);

					// $('#uptpzt').html(html);

                } else {
					//msgWrapper.innerHTML += '';
					//document.getElementById("msgWrapper").innerHTML=oReq.status;

                }
            };

            oReq.send(formData);
        }

		$("#uptpzt").click(function(){
        $("#idzfilezt").click();
});
$("#uptpztzt").click(function(){
        $("#idzfilezt").click();
});
//用户头像上传
	$("#idzfilezt").change(function(){
	//console.log('头像主图');
    lrz(this.files[0],{width:800})
    .then(function (rst) {
        // 处理成功会执行
		//$('#shopimgdata').html('<img src="/Public/images/dd.gif">');
		Toast('图片已经提交请耐心等待',5500)
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idzfile2';
		//console.log(img.src);
		uploadPictx(img.src);
       // up_ajax(rst.base64,type);

    });
});

	$("#photoFile").change(function(){
	//console.log('主图');
    lrz(this.files[0],{width:800})
    .then(function (rst) {
        // 处理成功会执行
		Toast('图片已经提交请耐心等待',5500)
        var img = new Image();
        img.src = rst.base64;
        var type;
        type = 'idzfile2';
		//console.log(img.src);
		uploadPic(img.src);
       // up_ajax(rst.base64,type);

    });
});

function Toast(msg,duration){  
    duration=isNaN(duration)?3000:duration;  
    var m = document.createElement('div');  
    m.innerHTML = msg;  
    m.style.cssText="width: 60%;min-width: 150px;opacity: 0.7;height: 30px;color: rgb(255, 255, 255);line-height: 30px;text-align: center;border-radius: 5px;position: fixed;top: 40%;left: 20%;z-index: 999999;background: rgb(0, 0, 0);font-size: 12px;";  
    document.body.appendChild(m);  
    setTimeout(function() {  
        var d = 0.5;  
        m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';  
        m.style.opacity = '0';  
        setTimeout(function() { document.body.removeChild(m) }, d * 1000);  
    }, duration);  
}  
	</script>
	<script src="/qstatic/js/lrz/lrz.all.bundle.js" type="text/javascript"></script>
</body>
</html>
